/*
 * @Descripttion:
 * @version:
 * @Author: lfzxs@qq.com
 * @Date: 2023-06-21 15:47:32
 * @LastEditors: lfzxs@qq.com
 * @LastEditTime: 2023-06-21 15:52:22
 */
package goframe206

import (
	"context"

	"gitee.com/g_boot/configkit/adapter"
	"gitee.com/g_boot/configkit/config"
)

type CfgAdapter struct {
	ConfigSvr config.YamlConfig
}

func BuildDefault(fileName string, searchFolds ...string) (cfgadapter CfgAdapter, err error) {
	result := CfgAdapter{}

	cfg, err := adapter.YamlConfigFromFolders(fileName, searchFolds...)

	result.ConfigSvr = cfg
	return result,err
}


func (sf *CfgAdapter) Available(ctx context.Context, resource ...string) (ok bool) {
	return true
}

func (sf *CfgAdapter) Get(ctx context.Context, pattern string) (value interface{}, err error) {
	value = sf.ConfigSvr.GetValue(pattern)
	return value, err
}

func (sf *CfgAdapter) Data(ctx context.Context) (data map[string]interface{}, err error) {
	data = sf.ConfigSvr.Data
	return
}
